#include <cstdlib>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>

void *update();
int main();
unsigned int next(unsigned int );

const unsigned int A = 1664525, C = 1013904223;
const unsigned int MAX = 4294967295;
const int N = 8;

unsigned long pointsIn[40];
unsigned int x[40],y[40];

void *update(void *t) {
  long index = (long)t;
  int i = 1000000000/N;
  long pIn = 0;

  unsigned int xl = x[index];
  unsigned int yl = y[index];
  float px;
  float py;

  while (i) {
    i--;
    px = (float)xl/MAX - 0.5;
    py = (float)yl/MAX - 0.5;

    if ((px*px + py*py) <= 0.25)
      pIn++;

    xl = yl*A+C;
    yl = xl*A+C;
  }
  pointsIn[index] = pIn;
}

unsigned int next(unsigned int x) {
  return x*A+C;
}

int main() {
  srand (time(NULL));
  x[0] = next(time(NULL));
  y[0] = next(x[0]);
  for (int i=1;i<N;i++) {
    x[i] = next(x[i-1]+rand());
    y[i] = next(x[i]);
  }
  pthread_t threads[40];
  int t;
  for (long i=0;i<N;i++) {
    pthread_create(&threads[i], NULL, update, (void *)i);
  }
  for(int i=0; i<N; i++) {
    pthread_join(threads[i], NULL);
  }
  long pointsInTotal = 0;

  for(int i=0; i<N; i++) {
    pointsInTotal += pointsIn[i];
  }
  printf("%.6f\n",(float)4*((float)pointsInTotal)/
       ((float)1000000000));
  return 0;
}
